<%@page import="java.io.PrintWriter"%>
<%@page import="model.UserInfoBase"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<style>
.mbtn{width: 100%;  height:25px; float:left; background-color:#0f5fa7;}
.mbtn .mbtn_div{width:30px; height:25px; background-color:#0f5fa7; float:left;}
.mbtn .mbtn_page_show{
	width:200px; height:22px; background-color:#0f5fa7; float:right;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: normal;
	font-size: 14px;
	color: #000000;
	display: inline-block;
	background-color:#0f5fa7;}
.mbtn .mbtn_black{width:30% ; height:25px; background-color:#0f5fa7; float:left;}
.mbtn .mbtn_btn{
	background:url(assets/img/page_index.png);
	border:0px;
	min-width:25px;
	min-height:25px;
	background-color:#0f5fa7
}
.mbtn .mbtn_btn_select{
	background:url(assets/img/page_select.png);
	border:0px;
	min-width:25px;
	min-height:25px;
	background-color:#0f5fa7
}

.page_font
{
	width:200px; height:22px; background-color:#0f5fa7; float:right;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: normal;
	font-size: 16px;
	color: #FFFFFF;
}
</style>


<div class="mbtn">
<%
	String user = (String)request.getSession().getAttribute("username");
	UserInfoBase pageChangeInfo = (UserInfoBase)request.getSession().getAttribute(user);
	PrintWriter outpage = response.getWriter();
	
	int curpage = pageChangeInfo.page;
	int maxpage = pageChangeInfo.pageManeger.getTotalPage();
	%>
	<div class="mbtn_black">
	</div>

	<%
	if(curpage<5){
		if(maxpage <10){
			for(int i=0;i<maxpage;i++){
				String action_page_change = new String("PageChange?page="+i+"&"+"username="+user);
				String btn_stype;
				if(i==curpage){
					btn_stype = "mbtn_btn_select";
				}else{
					btn_stype = "mbtn_btn";
				}
				%>
					<div class="mbtn_div">
					<form action=<%=action_page_change %> method="post">
					<button type="submit" class=<%=btn_stype %>><%=i %></button>
					</form>
					</div>
				<%
			}
		}else{
			for(int i=0;i<10;i++){
				String action_page_change = new String("PageChange?page="+i+"&"+"username="+user);
				String btn_stype;
				if(i==curpage){
					btn_stype = "mbtn_btn_select";
				}else{
					btn_stype = "mbtn_btn";
				}
				%>
					<div class="mbtn_div">
					<form action=<%=action_page_change %> method="post">
					<button type="submit" class=<%=btn_stype %>><%=i %></button>
					</form>
					</div>
				<%
			}
		}
	}else{
		int start = curpage-5;
		int end   = 0;
		if(curpage+4 > maxpage){
			end = maxpage;
		}else{
			end = curpage+4;
		}
		for(int i=start;i<end+1;i++){
			String action_page_change = new String("PageChange?page="+i+"&"+"username="+user);
			String btn_stype;
			if(i==curpage){
				btn_stype = "mbtn_btn_select";
			}else{
				btn_stype = "mbtn_btn";
			}
			%>
				<div class="mbtn_div">
				<form action=<%=action_page_change %> method="post">
				<button type="submit" class=<%=btn_stype %>><%=i %></button>
				</form>
				</div>
			<%
		}
		
	}
	
%>
<div class="mbtn_page_show">
<p class ="page_font">【第<%=curpage+1 %>页】--【共<%=maxpage %>页】</p>
</div>
</div>
</body>
</html>